#include <stdio.h>

int isUgly(int n){
    if(n == 1){
        return 0;
    }
    while (n % 2 == 0) {
        n= n / 2 ;
    }
    while (n % 3 == 0) {
        n = n / 3;
    }
    while (n % 5 == 0) {
        n = n / 5;
    }
    return n == 1;
}

int main() {
    int n = 0;
    scanf("%d", &n);
    if(isUgly(n)){
        printf("%d",1);
        return 1;
    }else{
        printf("%d",0);
        return 0;
    }
}
